Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@turf/kinks
Advanced tools
@turf/kinks is a module in the Turf.js library that is used to detect self-intersections (kinks) in GeoJSON polygons. This is useful for validating and cleaning up spatial data to ensure that polygons are well-formed and do not contain any self-intersecting lines.
Detecting Kinks in Polygons
This feature allows you to detect self-intersections in a given GeoJSON polygon. The code sample creates a polygon with a self-intersection and uses the `turf.kinks` function to find and log the kinks.
const turf = require('@turf/turf');
const polygon = turf.polygon([[
[-12.034835, 8.901183],
[-12.060413, 8.899826],
[-12.03638, 8.873199],
[-12.034835, 8.901183]
]]);
const kinks = turf.kinks(polygon);
console.log(kinks);
JSTS (JavaScript Topology Suite) is a JavaScript library of spatial predicates and functions for processing geometry. It provides more comprehensive geometry operations compared to @turf/kinks, including robust algorithms for intersection, union, and difference operations.
Martinez Polygon Clipping is a library for performing boolean operations on polygons, such as union, intersection, and difference. While it does not specifically focus on detecting kinks, it can be used to handle complex polygon operations and ensure valid geometries.
Takes a linestring, multi-linestring, multi-polygon, or polygon and returns points at all self-intersections.
Parameters
featureIn
Feature<(LineString | MultiLineString | MultiPolygon | Polygon)> input featureExamples
var poly = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-12.034835, 8.901183],
[-12.060413, 8.899826],
[-12.03638, 8.873199],
[-12.059383, 8.871418],
[-12.034835, 8.901183]
]]
}
};
var kinks = turf.kinks(poly);
var resultFeatures = kinks.features.concat(poly);
var result = {
"type": "FeatureCollection",
"features": resultFeatures
};
//=result
Returns FeatureCollection<Point> self-intersections
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this module individually:
$ npm install @turf/kinks
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
FAQs
turf kinks module
The npm package @turf/kinks receives a total of 515,206 weekly downloads. As such, @turf/kinks popularity was classified as popular.
We found that @turf/kinks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.